{extend name="../../admin/view/public/admin"}

{block name='content'}

<style type='text/css'>
    .trhead td {
        background: #efefef;
        text-align: center
    }

    .trbody td {
        text-align: center;
        vertical-align: top;
        border-left: 1px solid #f2f2f2;
        overflow: hidden;
        font-size: 12px;
    }

    .trorder {
        background: #f8f8f8;
        border: 1px solid #f2f2f2;
        text-align: left;
    }

    .ops {
        border-right: 1px solid #f2f2f2;
        text-align: center;
    }

    .ops a, .ops span {
        margin: 3px 0;
    }

    .table-top .op:hover {
        color: #000;
    }

    .tables {
        border: 1px solid #e5e5e5;
        font-size: 12px;
        line-height: 18px;
    }

    .tables:hover {
        border: 1px solid #b1d8f5;
    }

    .table-row, .table-header, .table-footer, .table-top {
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        justify-content: center;
        -webkit-justify-content: center;
        -webkit-align-content: space-around;
        align-content: space-around;
    }

    .tables .table-row > div {
        padding: 14px 0 !important;
    }

    .tables .table-row.table-top > div {
        padding: 11px 0;
    }

    .tables .table-row .ops.list-inner {
        border-right: none;
    }

    .tables .list-inner {
        border-right: 1px solid #efefef;
        vertical-align: middle;
    }

    .table-row .goods-des .title {
        width: 180px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .table-row .goods-des {
        width: 300px;
        border-right: 1px solid #efefef;
        vertical-align: middle;
    }

    .table-row .list-inner {
        -webkit-box-flex: 1;
        -webkit-flex: 1;
        -ms-flex: 1;
        flex: 1;
        text-align: center;
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        -webkit-align-items: center;
        align-items: center;
        -webkit-justify-content: center;
        justify-content: center;
        -webkit-flex-direction: column;
        flex-direction: column;
    }

    .saler > div {
        width: 130px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .table-row .list-inner.ops, .table-row .list-inner.paystyle {
        -webkit-flex-direction: column;
        flex-direction: column;
        -webkit-justify-content: center;
        justify-content: center;
    }

    .table-header .others {
        -webkit-box-flex: 1;
        -webkit-flex: 1;
        -ms-flex: 1;
        flex: 1;
        text-align: center;
    }

    .table-footer {
        border-top: 1px solid #efefef;
    }

    .table-footer > div, .table-top > div {
        -webkit-box-flex: 1;
        -webkit-flex: 1;
        -ms-flex: 1;
        flex: 1;
        height: 100%;
    }

    .fixed-header div {
        padding: 0;
    }

    .fixed-header.table-header {
        display: none;
    }

    .fixed-header.table-header.active {
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
    }

    .shop {
        display: inline-block;
        width: 48px;
        height: 18px;
        text-align: center;
        border: 1px solid #1b86ff;
        color: #1b86ff;
        margin-right: 10px;
    }

    .min_program {
        display: inline-block;
        width: 48px;
        height: 18px;
        text-align: center;
        border: 1px solid #ff5555;
        color: #ff5555;
        margin-right: 10px;
    }
</style>

<div class="page-header">
    当前位置：<span class="text-primary">订单管理</span>
    <span>订单数:  <span class='text-danger'>{$total}</span> 订单金额:  <span class='text-danger'>￥{$totalMoney ? $totalMoney : 0.00}</span> </span>
</div>

<div class="page-content">
    <div class="fixed-header table-header" style="padding: 0 50px;right: 50px;left: 294px;">
        <div style='border-left:1px solid #f2f2f2;width: 400px;text-align: left;'>商品</div>
        <div class="others">买家</div>
        <div class="others">支付/配送</div>
        <div class="others">价格</div>
        <div class="others">操作</div>
        <div class="others">状态</div>
    </div>
    <form action="" method="get" class="form-horizontal table-search" role="form" id="search">
        <input type="hidden" name="status" value="{$status}"/>
        <input type="hidden" name="refund" value="{$_GET['refund']}"/>
        <div class="page-toolbar">
            <div class="input-group">
                <span class="input-group-select">
                    <select name="paytype" class="form-control" style="width:100px;padding:0 5px;">
                        <option value="" {if $_GET['paytype']==''}selected{/if}>支付方式</option>
                        {foreach $paytype as $key => $type}
                        <option value="{$key}" {if $_GET['paytype'] == "$key"} selected="selected" {/if}>{$type['name']}</option>
                        {/foreach}
                    </select>
                </span>
                <span class="input-group-select">
                    <select name='searchtime' class='form-control' style="width:100px;padding:0 5px;" id="searchtime">
                        <option value=''>不按时间</option>
                        <option value='create' {if $_GET['searchtime']=='create'}selected{/if}>下单时间</option>
                        <option value='pay' {if $_GET['searchtime']=='pay'}selected{/if}>付款时间</option>
                        <option value='send' {if $_GET['searchtime']=='send'}selected{/if}>发货时间</option>
                        <option value='finish' {if $_GET['searchtime']=='finish'}selected{/if}>完成时间</option>
                    </select>
                </span>
                <span class="input-group-btn">
                    {:tpl_form_field_daterange('time', array('starttime'=>date('Y-m-d H:i', $starttime),'endtime'=>date('Y-m-d H:i', $endtime)),true);}
                </span>
                <span class="input-group-select">
                    <select name='searchfield' class='form-control' style="width:110px;padding:0 5px;">
                        <option value='ordersn' {if $_GET['searchfield']=='ordersn'}selected{/if}>订单号</option>
                        <option value='member' {if $_GET['searchfield']=='member'}selected{/if}>会员信息</option>
                        <option value='address' {if $_GET['searchfield']=='address'}selected{/if}>收件人信息</option>
                        <option value='location' {if $_GET['searchfield']=='location'}selected{/if}>地址信息</option>
                        <option value='expresssn' {if $_GET['searchfield']=='expresssn'}selected{/if}>快递单号</option>
                        <option value='goodstitle' {if $_GET['searchfield']=='goodstitle'}selected{/if}>商品名称</option>
                        <option value='goodssn' {if $_GET['searchfield']=='goodssn'}selected{/if}>商品编码</option>
                    </select>
                </span>
                <input type="text" class="form-control input-sm" name="keyword" id="keyword" value="{$_GET['keyword']}" placeholder="请输入关键词"/>
                <input type="hidden" name="export" id="export" value="0">
                <span class="input-group-btn">
                    <button type="button" data-export="0" class="btn btn-primary btn-submit"> 搜索</button>
                    <button type="button" data-export="1" class="btn btn-success btn-submit">导出</button>
                </span>
            </div>
        </div>
    </form>

    {if count($list)>0}
    <div class="row">
        <div class="col-md-12">
            <div class="">
                <div class="table-header" style='background:#f8f8f8;height: 35px;line-height: 35px;padding: 0 20px'>
                    <div style='border-left:1px solid #f2f2f2;width: 400px;text-align: left;'>商品</div>
                    <div class="others">买家</div>
                    <div class="others">支付/配送</div>
                    <div class="others">价格</div>
                    <div class="others">操作</div>
                    <div class="others">状态</div>
                </div>

                {foreach $list as $key => $item}
                <div class="table-row">
                    <div style='height:20px;padding:0;border-top:none;'>&nbsp;</div>
                </div>

                <div class="tables">
                    <div class='table-row table-top' style="padding:0  20px;background: #f7f7f7">
                        <div style="text-align: left;color: #8f8e8e;">
                            <span style="font-weight: bold;margin-right: 10px;color: #2d2d31">
                                {:date('Y-m-d',$item['createtime'])}&nbsp {:date('H:i:s',$item['createtime'])}
                            </span>
                            订单编号: {$item['ordersn']}
                        </div>
                        <div style='text-align:right;font-size:12px;' class='aops'>
                            <a class='op' data-toggle="ajaxModal" href="{:webUrl('web.order.op/remarksaler', array('id' => $item['id']))}">
                                {if !empty($item['remark'])}
                                <i class="icow icow-flag-o" style="color: #df5254;display: inline-block;vertical-align: middle" title="  查看备注"></i>
                                备注
                                &nbsp
                                {else /}
                                <i class="icow icow-yibiaoji" style="color: #999;display: inline-block;vertical-align: middle" title="  添加备注"></i>
                                备注
                                &nbsp
                                {/if}
                            </a>
                            {if ($item['statusvalue']>=2 || $item['sendtype']>0) && !empty($item['addressid']) && $item['statusvalue']!=3 &&$item['city_express_state']==0}
                            <a class="op" data-toggle="ajaxModal" href="{:webUrl('web.order.op/changeexpress', array('id' => $item['id']))}">
                                <i class="icow icow-wuliu" title="修改物流" style="color: #999;display: inline-block;vertical-align: middle"></i>
                                修改物流
                                &nbsp
                            </a>
                            {/if}
                            {if empty($item['status'])}
                            <a class='op' data-toggle='ajaxModal' href="{:webUrl('web.order.op/changePrice',array('id'=>$item['id']))}">
                                <i class="icow icow-gaijia" title="订单改价" style="color: #999;display: inline-block;vertical-align: middle"></i>
                                订单改价
                                &nbsp
                            </a>
                            <a class='op' data-toggle='ajaxModal' href="{:webUrl('web.order.op/close',array('id'=>$item['id']))}">
                                <i class="icow icow-shutDown" title="关闭订单" style="color: #999;margin-right: 3px;display: inline-block;vertical-align: middle"></i>
                                关闭订单
                                &nbsp
                            </a>
                            {/if}
                        </div>
                    </div>
                    <div class='table-row' style="margin:0  20px">
                        <div class="goods-des" style='width:400px;text-align: left'>
                            {foreach $item['goods'] as $k => $g}
                            <div style="display: -webkit-box;display: -webkit-flex;display: -ms-flexbox;display: flex;margin: 10px 0">
                                <img src="{:tomedia($g['thumb'])}" style='width:70px;height:70px;border:1px solid #efefef; padding:1px;object-fit: contain;' onerror="this.src='/app/admin/static/images/default-pic.jpg'">
                                <div style="-webkit-box-flex: 1;-webkit-flex: 1;-ms-flex: 1;flex: 1;margin-left: 10px;text-align: left;display: flex;align-items: center">
                                    <div>
                                        <div class="title">
                                            {if $g['ispresell']==1}
                                            <label class="fui-tag fui-tag-danger">预</label>
                                            {/if}
                                            {$g['title']}<br/>
                                            <span style="color: #999"> {if !empty($g['optiontitle'])}{$g['optiontitle']}{/if}{$g['goodssn']}</span>
                                        </div>

                                        <!--赠品-->
                                        {if $g['seckill_task']}
                                        <div>
                                            <span class="label label-danger">{$g['seckill_task']['tag']}</span>
                                            {if $g['seckill_room']}
                                            <span class="label label-primary">
                                                {:$g['seckill_room']['tag']?:$g['seckill_room']['title']}
                                            </span>
                                            {/if}
                                        </div>
                                        {/if}

                                    </div>
                                    <span style="float: right;text-align: right;display: inline-block;width:130px;">
                                        {if $item['service_type'] == '1'}
                                            ￥{:number_format($g['price']/$g['total'],2)}
                                            <br/>x{$g['total']}
                                        {else}
                                            ￥{:number_format($g['price'],2)}
                                        {/if}
                                    </span>
                                </div>
                            </div>
                            {/foreach}
                        </div>
                        <div class="list-inner saler" style='text-align: center;'>
                            <div>
                                <a href="{:webUrl('web.member/edit',array('id'=>$item['mid']))}"> {$item['member']['username']}</a>
                                <br/>
                                {$item['address']['realname']}<br/>{$item['address']['mobile']}
                            </div>
                        </div>
                        <div class="list-inner paystyle" style='text-align:center;'>
                            <!-- 已支付 -->
                            {if $item['statusvalue'] > 0}
                                {if $item['paytypevalue']==3}
                                    <span> <i class="icow icow-yue text-warning" style="font-size: 17px;"></i><span>余额支付</span></span>
                                {elseif $item['paytypevalue']==4 /}
                                    <span> <i class="icow icow-kuajingzhifuiconfukuan text-danger" style="font-size: 17px"></i>后台付款</span>
                                {elseif $item['paytypevalue']==1 /}
                                    <span> <i class="icow icow-weixinzhifu text-success" style="font-size: 17px"></i>微信支付</span>
                                {elseif $item['paytypevalue']==2 /}
                                    <span><i class="icow icow-zhifubaozhifu text-primary" style="font-size: 17px"></i>支付宝支付</span>
                                {else}
                                    <label class='label label-default'>未支付</label>
                                {/if}
                            {elseif $item['statusvalue'] == 0 /}
                                <!-- 未支付 -->
                                <label class='label label-default'>未支付</label>
                            {elseif $item['statusvalue'] == -1 /}
                                {if $item['paytypevalue']==3}
                                    <span> <i class="icow icow-yue text-warning" style="font-size: 17px;display:inline-block;height: 17px;width: 17px;padding-top: 3px"></i><span>余额支付</span></span>
                                {elseif $item['paytypevalue']==4 /}
                                    <span> <i class="icow icow-kuajingzhifuiconfukuan text-danger" style="font-size: 17px"></i>后台付款</span>
                                {elseif $item['paytypevalue']==1 /}
                                    <span> <i class="icow icow-weixin text-success" style="font-size: 17px"></i>微信支付</span>
                                {elseif $item['paytypevalue']==2 /}
                                    <span><i class="icow icow-zhifubao text-primary" style="font-size: 17px"></i>支付宝支付</span>
                                {else}
                                    <label class='label label-default'>未支付</label>
                                {/if}
                            {/if}
                        </div>
                        <a class="list-inner" data-toggle='popover' data-html='true' data-placement='right' data-trigger="hover"
                           data-content="<table style='width:100%;'>
                                    <tr>
                                        {if intval($item['service_type'])==1}
                                        <td style='border:none;text-align:right;'>商品小计：</td>
                                        {elseif intval($item['service_type'])==2}
                                        <td  style='border:none;text-align:right;'>课程小计：</td>
                                        {/if}
                                        <td  style='border:none;text-align:right;;'>￥{:number_format( $item['oldprice'] ,2)}</td>
                                    </tr>
                                    {if intval($item['service_type'])==1}
                                    <tr>
                                        <td  style='border:none;text-align:right;'>运费：</td>
                                        <td  style='border:none;text-align:right;;'>￥{:number_format( $item['olddispatchprice'],2)}</td>
                                    </tr>
                                    {/if}
                                    {if intval($item['changeprice'])!=0}
                                    <tr>
                                        <td  style='border:none;text-align:right;'>卖家改价：</td>
                                        <td  style='border:none;text-align:right;;'><span style='{if 0<$item['changeprice']}color:green{else /}color:red{/if}'>{if 0<$item['changeprice']}+{else /}-{/if}￥{:number_format(abs($item['changeprice']),2)}</span></td>
                                    </tr>
                                    {/if}
                                    {if intval($item['changedispatchprice'])!=0}
                                    <tr>
                                        <td  style='border:none;text-align:right;'>卖家改运费：</td>
                                        <td  style='border:none;text-align:right;;'><span style='{if 0<$item['changedispatchprice']}color:green{else}color:red{/if}'>{if 0<$item['changedispatchprice']}+{else}-{/if}￥{:abs($item['changedispatchprice'])}</span></td>
                                    </tr>
                                    {/if}
                                    <tr>
                                        <td style='border:none;text-align:right;'>应收款：</td>
                                        <td  style=`'border:none;text-align:right;color:green;'>￥{:number_format($item['price'],2)}</td>
                                    </tr>
                                </table>
                    ">
                            <div style='text-align:center'>
                                ￥{:number_format($item['price'],2)}
                                {if $item['dispatchprice']>0}
                                <br/>(含运费:￥{:number_format( $item['dispatchprice'],2)})
                                {/if}
                            </div>
                        </a>
                        <div class="list-inner" style='text-align:center'>
                            <a class='op text-primary' href="{:webUrl('web.order.index/detail', array('id' => $item['id']))}">查看详情</a>
                            {if !empty($item['refundid'])}
                            <a class='op  text-primary' href="{:webUrl('web.order.op/refund', array('id' => $item['id']))}">维权{if $item['refundstate']>0}处理{else /}详情{/if}</a>
                            {/if}
                            {if $item['addressid']!=0 && $item['statusvalue']>=2 && $item['sendtype']==0 && $item['city_express_state']==0}
                            <a class='op  text-primary' data-toggle="ajaxModal" href="{:webUrl('util/express', array('id' => $item['id'],'express'=>$item['express'],'expresssn'=>$item['expresssn']))}">物流信息</a>
                            {/if}
                            {if $item['city_express_state']==1}
                            <a class='op  text-primary' href="javascript:tip.msgbox.err('同城配送暂不支持物流信息查询');">物流信息</a>
                            {/if}
                        </div>
                        <div class='ops list-inner' style='line-height:20px;text-align:center'>
                            <span class="text-{$item['statuscss']}">{$item['statusname']}</span>
                            {include file='web/order/index/ops'}
                        </div>
                    </div>
                    {if !empty($item['remark'])}
                    <div class="table-row">
                        <div style='background:#fdeeee;color:red;flex: 1;'><p style="padding-left: 20px;box-sizing: border-box;">买家备注: {$item['remark']}</p></div>
                    </div>
                    {/if}
                </div>
                {/foreach}
                <div style="padding: 20px;text-align: right">
                    {$pager|raw}
                </div>
            </div>
        </div>
    </div>
    {else /}
    <div class="panel panel-default">
        <div class="panel-body empty-data">暂时没有任何订单!</div>
    </div>
    {/if}
</div>
<script>
    //没有选中时间段不能导出
    $(function () {
        $('.btn-submit').click(function () {
            var e = $(this).data('export');
            if (e == 1) {
                if ($('#keyword').val() != '') {
                    $('#export').val(1);
                    $('#search').submit();
                } else if ($('#searchtime').val() != '') {
                    $('#export').val(1);
                    $('#search').submit();
                } else {
                    tip.msgbox.err('请选择按时间导出!');
                    return;
                }
            } else {
                $('#export').val(0);
                $('#search').submit();
            }
        })
    })
</script>

{/block}